<%-- 
    Document   : index
    Created on : 14.11.2014, 19:39:42
    Author     : Bor
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <script src="./common/b4w.full.min.js"></script>
        <script>

            var m_app = b4w.require("app");
            var m_data = b4w.require("data");
            var m_scenes = b4w.require("scenes");
            var m_quat = b4w.require("quat");
            var m_transform = b4w.require("transform");

            m_app.init({
                canvas_container_id: "body_id",
                callback: load_cb
            });

            function load_cb() {
                m_data.load("untitled.json");
                // check if module exists
                if (b4w.module_check("my_module"))
                    throw "Failed to register module: my_module";

// register my_module
                b4w.register("my_module", function(exports, require) {

                    // import module "version"
                    var m_version = require("version");

                    // export print_build_date() from module "my_module"
                    exports.print_build_date = function() {
                        // exec function date() from module "version"
                        console.log("Engine build date: " + m_version.date());
                    };

                });

// import module "my_module"
                var m_my_module = b4w.require("my_module");

// exec function print_build_date() from module "my_module"
                m_my_module.print_build_date();

            }
            function rot() {
                alert(2);
                var aircraft = m_scenes.get_object_by_name("Cube");
                // compose quaternion
                var quat_60_Y_neg = m_quat.setAxisAngle([0, 1, 0], -Math.PI / 3, m_quat.create());

// get old rotation
                var quat_old = m_transform.get_rotation(aircraft);

// left multiply: quat60_Y_neg * quat_old
                var quat_new = m_quat.multiply(quat_60_Y_neg, quat_old, m_quat.create());
                alert(quat_new[1]);

// set new rotation
                m_transform.set_rotation_v(aircraft, quat_new);
                alert(3);

            }

        </script>
    </head>

    <body onclick="rot()" >111
        <hr/>
        <p id="body_id" ></p>
        <p >___</p>

    </body>

</html>